package algorithm.easy;

public class MaxProduct1464 {

    public static int maxProduct(int[] nums) {
        int max = 0;
        int second = 1;
        if (nums[1] > nums[0]) {
            max = 1;
            second = 0;
        }
        for (int i = 2; i < nums.length; i++) {
            if (nums[i]>nums[second]){
                if (nums[i] >= nums[max]) {
                    second = max;
                    max = i;
                }else {
                    second = i;
                }
            }
        }
        return (nums[max] - 1) * (nums[second] - 1);
    }

    public static void main(String[] args) {
        maxProduct(new int[]{10, 2, 5, 2});
    }
}
